package com.ktjiaoyu.service.impl;

import com.ktjiaoyu.entity.Flower;
import com.ktjiaoyu.mapper.FlowerMapper;
import com.ktjiaoyu.service.FlowerService;
import com.ktjiaoyu.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/12/23  10:06
 */
@Service("flowerService")
public class FlowerServiceImpl implements FlowerService {
    @Autowired
    private FlowerMapper flowerMapper;
    @Override
    public Page<Flower> pageList(Flower flower, Integer pageNo, Integer pageSize) {
        Page<Flower> page=new Page<>();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        //总页数
        Integer count=flowerMapper.count(flower);
        page.setTotalCount(count);
        Integer pageBegin=(pageNo-1)*pageSize;
        List<Flower> data=flowerMapper.pageList(flower,pageBegin,pageSize);
        page.setData(data);
        return page;
    }

    @Override
    public boolean insert(Flower flower) {
        return flowerMapper.insert(flower)>0;
    }

    @Override
    public boolean update(Flower flower) {
        return flowerMapper.update(flower)>0;
    }

    @Override
    public boolean delete(Integer flowerId) {
        return flowerMapper.delete(flowerId)>0;
    }

    @Override
    public Flower selectId(Integer flowerId) {
        return flowerMapper.selectId(flowerId);
    }

    @Override
    public Flower selectName(String flowerName) {
        return flowerMapper.selectName(flowerName);
    }
}
